<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>按配送企业设置配送区域</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
 	
   
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>按企业设置配送区域</h1>
        <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送关系设置</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
            
                <div class="input">
                   <div class="textalign1">企业名称：</div>
                    <div class="boxinput">
                        <input class="textinput" type="text" name="compName" id="compNameSearch" placeholder="企业名称" /> 
                    </div>
                   
                    <div class="textalign1">企业编码：</div>
                    <div class="boxinput">
                        <input class="textinput"  type="text" name="compCode" id="compCodeSearch" placeholder="企业编码"  /> 
                    </div>
                    
                    
                    <div class="textalign1" >
                       <button id="selectSee" type="button"  onclick="gridSerch()"  class="btn btn-success btn-sm">查&nbsp;询</button>
                    </div>       
                    
                    
               </div>    
                
            </div>
        </div>
         
        <table class="jqgrid" id="gridlist"></table>
        <div id="prowed2"></div>
        
		<div class=" box box-warning bottongroup" id="bottongroup">
		<label  onclick="window.location.href='${ctx}/baseDel/toDelDrugList.html'"   class="btn btn-danger btn-sm" >返 回</label>
		</div>
		<form action="${ctx}/baseDel/toDelArea.html" method="post" id="FormComp">
		<input type="hidden" id="delCompCode" name="compCode">
		<input type="hidden" id="compName" name="compName">
		<input type="hidden" id="goodsCode" name="goodsCode">
		<input type="hidden" id="projID" name="projID">
		<input type="hidden" name="areaCode" value="${param.areaCode}"> 
		</form>
		<form action="${ctx}/baseDel/toSetDelArea.html" method="post" id="FormDelComp">
		<input type="hidden" id="compId2" name="compId">
		<input type="hidden" id="compName2" name="compName">
		<input type="hidden" id="goodsCode2" name="goodsCode">
		<input type="hidden" id="projID2" name="projID">
		</form>
	<table class="jqgrid" id="gridlist"></table>
<div style="margin-top: 10px;"></div>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">

//绑定回车   id="selectSee"
$('#compNameSearch,#compCodeSearch').bind('keydown', function(event) {
    if (event.keyCode == "13") {
        $('#selectSee').click();
    }
}); 
$("#compNameSearch").focus();//加载页面光标在第一个查询框内


$(function () {
jQuery("#gridlist").jqGrid({
	url: "${ctx}/baseGoods/getDelComp.html",
    mtype: "POST",
	datatype: "json",
	postData:{"goodsCode":"${param.goodsCode}","projID":"${param.projID}","goodsArea":"${param.areaCode}"},
	autowidth: true,
//	height: 283,
   	colNames:['操作','企业编码','企业名称','组织机构代码','联系人','联系电话','配送区域数'],
   	colModel:[
         {name:'oper',index:'formName', width:60, align:"center", sorttype:false,sortable:false,formatter:function(val,option,rowdata){
		var str = "<a href=\"javascript:toCompJsp('"+rowdata.compCode+"','"+rowdata.compName+"')\" style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -20px -100px' class='opIcon' title='选择配送区域'></a>";
		str += "<a href='${ctx}/baseDel/toDelLogByCompList.html?compCode="+rowdata.compCode+"&compName="+rowdata.compName+"&goodsCode=${param.goodsCode}&projID=${param.projID}' style='background:url(${ctx}/lib/img/icon/icon.png) no-repeat -100px 0px' class='opIcon' title='设置日志'></a>";
		return str;
	    }},
		{name:'compCode',index:'compCode', width:100,align:"center", sorttype:false,sortable:false},
		{name:'compName',index:'compName', width:120, sorttype:"date",sortable:false},
   		{name:'orgCode',index:'orgCode', width:100,align:"center", sorttype:false,sortable:false},
   		{name:'contactName',index:'contactName', width:80,align:"center", sorttype:false,sortable:false},
   		{name:'contactTelephone',index:'contactPhone', width:80, sorttype:false,sortable:false},
   		{name:'areaCount',index:'count', width:50, align:"center", sorttype:false,sortable:false,formatter:function(val,option,rowdata){

   			var str = "<a href='${ctx}/baseDel/toSetDelArea.html?compCode="+rowdata.compCode+"&compName="+encodeURI(encodeURI(rowdata.compName))+"&goodsCode=${param.goodsCode}&projID=${param.projID}'>"+val+"</a>";
	   			return str;
   		}}
   		
		
   	],
	 rowNum: 20,
     rowList: [10, 20, 50,100],
     rownumbers: true,
     pager: "#prowed2",
     viewrecords: true,
	gridComplete: function(){
	//序号列宽度自适应（参数为jqgridID）
	 autoRNWidth("gridlist");
	//数据只有一条时默认选中（参数为jqgridID）
	 selectByOneData("gridlist");
	 },
     caption: "${form.goods_code}/${form.qualityspec_name}/${form.form_name}/${form.spec_name}/${form.factor}/${form.unit_name}/${form.material_name}/${form.prod_compname}",
     editurl:"proPlanItemListHis.jsp",
     jsonReader: {
         repeatitems: false,
         id: "ids"
     }
   	
});
	jQuery("#gridlist").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
	$(window).trigger("resize");
	$("#gridlist").jqGrid("setGridHeight", create());

});

function gridSerch() {
	var compCode = $.trim($("#compCodeSearch").val());
	var compName = $.trim($("#compNameSearch").val());
	$("#gridlist").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{
        	"compCode":compCode,
        	"compName":compName,
        	"projID":"${param.projID}",
        		"goodsCode":"${param.goodsCode}"}
    }).trigger("reloadGrid"); //重新载入  
}


function toCompJsp(compCode,compName){
	$("#delCompCode").val(compCode);
	$("#compName").val(compName);
	$("#goodsCode").val("${param.goodsCode}");
	$("#projID").val("${param.projID}");
	$("#FormComp").submit();
}

function toDelCompJsp(compId,compName){
	$("#compId2").val(compId);
	$("#compName2").val(compName);
	$("#goodsCode2").val("${param.goodsCode}");
	$("#projID2").val("${param.projID}");
	$("#FormDelComp").submit();
}
</script>
</body>
</html>